home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / manchester / 4.1 / Character-printOn.st < prev    next >
Text File  |  1993-07-24  |  974b  |  34 lines

  1. "    NAME        Character-printOn
  2.     AUTHOR        Bernard Horan <bernard@is.morgan.com>
  3.     CONTRIBUTOR    Bernard Horan <bernard@is.morgan.com>
  4.     FUNCTION     produce _useful_ representation of character instance
  5.     ST-VERSIONS    4.1
  6.     PREREQUISITES     
  7.     CONFLICTS     
  8.     DISTRIBUTION    global
  9.     VERSION        1.0
  10.     DATE        September 1992
  11.     SUMMARY        Alternative method to print a character, possibly as an ascii value, if that value is non-alphabetic. BH, 28/9/92"
  12. !
  13.  
  14. 'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 1 September 1992 at 6:46:35 am'!
  15.  
  16.  
  17.  
  18. !Character methodsFor: 'printing'!
  19.  
  20. printOn: aStream 
  21.     "If I am alphabetic, then append to the argument aStream a sequence of characters preceded by 
  22.     the 
  23.     literal $ that identifies the receiver; otherwise append my integer value (ascii).
  24.     Bernard Horan, 29 September 1992."
  25.  
  26.     aStream nextPut: $$.
  27.     self isAlphabetic
  28.         ifTrue: [aStream nextPut: self]
  29.         ifFalse: 
  30.             [aStream nextPut: ${.
  31.             self asInteger printOn: aStream.
  32.             aStream nextPut: $}]! !
  33.  
  34.